﻿@{
    var membershipUser = ViewContext.HttpContext.Membership().GetMembershipUser();
    var cultures = System.Globalization.CultureInfo.GetCultures(System.Globalization.CultureTypes.SpecificCultures).OrderBy(c => c.DisplayName);
    var timeZoneHelper = Kooboo.CMS.Common.Runtime.EngineContext.Current.Resolve<Kooboo.CMS.Common.ITimeZoneHelper>();
    var timeZones = timeZoneHelper.GetTimeZones();
}
<div class="block member-form common-form">
    <form class="ajaxForm" action="@Url.FrontUrl().SubmissionUrl("EditMemberProfile")" method="post">
        @Html.ValidationSummary(true)
        @Html.AntiForgeryToken()
        <table class="member-form-main single">

            @if (string.IsNullOrEmpty(membershipUser.Email))
            {
                <tr class="field">
                    <th>
                        <label for="Email">@("Email".Label())</label>
                    </th>
                    <td>
                        <input id="Email" name="Email" type="text" value="@membershipUser.Email" @(new[] { Validator.Required("Required").ClientValidationRule, Validator.Regex(RegexPatterns.EmailAddress, "Invalid email").ClientValidationRule }.GenerateHtmlAttributes())>
                        @Html.ValidationMessageForInput("Email")
                    </td>
                </tr>
            }

            <tr class="field">
                <th>
                    <label for="FirstName">@("First name".Label())</label>
                </th>
                <td>
                    <input id="FirstName" name="FirstName" type="text" value="@membershipUser.GetProfile("FirstName")">
                    @Html.ValidationMessageForInput("FirstName")
                </td>
            </tr>
            <tr class="field">
                <th>
                    <label for="LastName">@("Last name".Label())</label>
                </th>
                <td>
                    <input id="LastName" name="LastName" type="text" value="@membershipUser.GetProfile("LastName")">
                    @Html.ValidationMessageForInput("LastName")
                </td>
            </tr>
            <tr class="field">
                <th>
                    <label for="Age">@("Age".Label())</label>
                </th>
                <td>
                    <input id="Age" name="Age" type="text" value="@membershipUser.GetProfile("Age")">
                    @Html.ValidationMessageForInput("Age")
                </td>
            </tr>
            <tr class="field">
                <th>
                    <label for="Culture">@("Culture".Label())</label>
                </th>
                <td>
                    <select id="Culture" name="Culture" type="text" value="@membershipUser.Culture">
                        @foreach (var c in cultures)
                        {

                            <option value="@c.Name" @(membershipUser.Culture == c.Name ? "selected" : "")>@c.NativeName</option>                            
                        }
                    </select>
                    @Html.ValidationMessageForInput("Culture")
                </td>
            </tr>
            <tr class="field">
                <th>
                    <label for="TimeZone">@("Time zone".Label())</label>
                </th>
                <td>

                    <select id="TimeZone" name="TimeZoneId" type="text" value="@membershipUser.TimeZoneId">
                        @foreach (var t in timeZones)
                        {

                            <option value="@t.Id" @(membershipUser.TimeZoneId == t.Id ? "selected" : "")>@t.DisplayName</option>                            
                        }
                    </select>
                    @Html.ValidationMessageForInput("TimeZone")
                </td>
            </tr>
            <tr>
                <th></th>
                <td>
                    <button type="submit">@("Update".Label())</button>
                </td>
            </tr>
        </table>
    </form>
</div>
